###################################################################
##  : Advanced Bonus System MOD for TorrentPier (SVN)
##   : Porutchik http://forum.aeroion.ru
##    TorrentPier: _Xz_
## :      
###################################################################

#
#-----[ SQL  ]------------------------------------------
#

ALTER TABLE bb_forums ADD points_disabled TINYINT(1) NOT NULL;
ALTER TABLE bb_users ADD admin_allow_points TINYINT(1) DEFAULT '1' NOT NULL;
INSERT INTO bb_config VALUES ('points_post', '1');
INSERT INTO bb_config VALUES ('points_poll', '1');
INSERT INTO bb_config VALUES ('points_donate', '1');
INSERT INTO bb_config VALUES ('points_reply', '5');
INSERT INTO bb_config VALUES ('points_topic', '20');
INSERT INTO bb_config VALUES ('points_vote', '10');
INSERT INTO bb_config VALUES ('points_user_group_auth_ids', '');

#
#-----[  ]------------------------------------------
#
admin/admin_forums.php

#
#-----[  ]------------------------------------------
#

				$allow_porno_topic = $row['allow_porno_topic'];

#
#-----[   ]------------------------------------------
#

				$points_disabled = $row['points_disabled'];

#
#-----[  ]------------------------------------------
#
				$allow_porno_topic = 0;

#
#-----[   ]------------------------------------------
#
				$points_disabled = 0;

#
#-----[  ]------------------------------------------
#
				'ALLOW_PORNO_TOPIC' => build_select('allow_porno_topic', array($lang['NONE'] => 0, $lang['YES'] => 1), $allow_porno_topic),

#
#-----[   ]------------------------------------------
#
				'POINTS_DISABLED' => build_select('points_disabled', array($lang['NONE'] => 0, $lang['YES'] => 1), $points_disabled),
#
#-----[  ]------------------------------------------
#

			$allow_porno_topic = (int) $_POST['allow_porno_topic'];

#
#-----[   ]------------------------------------------
#
			$points_disabled = (int) $_POST['points_disabled'];

#
#-----[  ]------------------------------------------
#
			$columns = ' forum_name,   cat_id,   forum_desc,   forum_order,  forum_status,  prune_days,  forum_parent,  show_on_index,  forum_display_sort,  forum_display_order,  forum_tpl_id,  allow_reg_tracker,  allow_porno_topic,

#
#-----[   ]------------------------------------------
#
 points_disabled,

#
#-----[  ]------------------------------------------
#
			$values = "'$forum_name', $cat_id, '$forum_desc', $forum_order, $forum_status, $prune_days, $forum_parent, $show_on_index, $forum_display_sort, $forum_display_order, $forum_tpl_id, $allow_reg_tracker, $allow_porno_topic,
#
#-----[   ]------------------------------------------
#

 $points_disabled,

#
#-----[  ]------------------------------------------
#

			$allow_porno_topic = (int) $_POST['allow_porno_topic'];

#
#-----[   ]------------------------------------------
#

			$points_disabled = (int) $_POST['points_disabled'];

#
#-----[  ]------------------------------------------
#

					allow_porno_topic   = $allow_porno_topic,

#
#-----[   ]------------------------------------------
#

					points_disabled     = $points_disabled,

#
#-----[  ]------------------------------------------
#

						'PRUNE_DAYS' => ($forum_rows[$j]['prune_days']) ? $forum_rows[$j]['prune_days'] : '-',

#
#-----[   ]------------------------------------------
#

						'POINTS_DISABLED' => ($forum_rows[$j]['points_disabled']) ? $forum_rows[$j]['points_disabled'] : '-',

#
#-----[  ]------------------------------------------
#
templates/admin/admin_forums.tpl

#
#-----[  ]------------------------------------------
#
	<tr>
	    <td class="row1">{L_REG_TORRENTS}</td>
	    <td class="row2">{ALLOW_REG_TRACKER} &nbsp; {L_SELF_MODERATED}: {SELF_MODERATED}  &nbsp; {L_ALLOW_PORNO_TOPIC}: {ALLOW_PORNO_TOPIC}</td>
    </tr>
#
#-----[   ]------------------------------------------
#
	<tr>
	    <td class="row1">{L_POINTS_DISABLED}</td>
	    <td class="row2">{POINTS_DISABLED}</td>
    </tr>
#
#-----[  ]------------------------------------------
#

		<td class="small" align="center" nowrap="nowrap">{catrow.forumrow.PRUNE_DAYS}</td>

#
#-----[   ]------------------------------------------
#

		<td class="small" align="center" nowrap="nowrap">{catrow.forumrow.POINTS_DISABLED}</td>

#
#-----[  ]------------------------------------------
#

admin_board.php

#
#-----[  ]------------------------------------------
#
		    'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'],
#
#-----[   ]------------------------------------------
#
			'POINTS_POST' => $new['points_post'],
			'POINTS_POLL' => $new['points_poll'],
			'POINTS_DONATE' => $new['points_donate'],
			'POINTS_REPLY' => $new['points_reply'],
			'POINTS_TOPIC' => $new['points_topic'],
			'POINTS_VOTE' => $new['points_vote'],
			'POINTS_USER_GROUP_AUTH_IDS' => $new['points_user_group_auth_ids'],

#
#-----[  ]------------------------------------------
#

admin_board.tpl

#
#-----[  ]------------------------------------------
#

<tr>
	<td><h4>{L_SEED_BONUS}</h4></td>
	<td>
	    <label><input type="radio" name="seed_bonus_enabled" value="1" <!-- IF SEED_BONUS_ENABLED -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
		<label><input type="radio" name="seed_bonus_enabled" value="0" <!-- IF not SEED_BONUS_ENABLED -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
	</td>
</tr>

#
#-----[   ]------------------------------------------
#
<tr>
	<td><h4>{L_POINTS_ENABLE_POST}</h4></td>
	<td>
	    <label><input type="radio" name="points_post" value="1" <!-- IF POINTS_POST -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
		<label><input type="radio" name="points_post" value="0" <!-- IF not POINTS_POST -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
	</td>
</tr>
<tr>
	<td><h4>{L_POINTS_ENABLE_POLL}</h4></td>
	<td>
	    <label><input type="radio" name="points_poll" value="1" <!-- IF POINTS_POLL -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
		<label><input type="radio" name="points_poll" value="0" <!-- IF not POINTS_POLL -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
	</td>
</tr>
<tr>
	<td><h4>{L_POINTS_ENABLE_DONATION}</h4></td>
	<td>
	    <label><input type="radio" name="points_donate" value="1" <!-- IF POINTS_DONATE -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
		<label><input type="radio" name="points_donate" value="0" <!-- IF not POINTS_DONATE -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
	</td>
</tr>

<tr>
	<td><h4>{L_POINTS_PER_REPLY}</h4></td>
	<td><input class="post" type="text" size="25" maxlength="100" name="points_reply" value="{POINTS_REPLY}" /></td>
</tr>
<tr>
	<td><h4>{L_POINTS_PER_TOPIC}</h4></td>
	<td><input class="post" type="text" size="25" maxlength="100" name="points_topic" value="{POINTS_TOPIC}" /></td>
</tr>
<tr>
	<td><h4>{L_POINTS_PER_VOTE}</h4></td>
	<td><input class="post" type="text" size="25" maxlength="100" name="points_vote" value="{POINTS_VOTE}" /></td>
</tr>
<tr>
    <td><h4>{L_POINTS_USER_GROUP_AUTH}</h4></td>
    <td><textarea name="points_user_group_auth_ids" rows="5" cols="35" class="post">{POINTS_USER_GROUP_AUTH_IDS}</textarea></td>
</tr>			
#
#-----[  ]------------------------------------------
#

modcp.php

#
#-----[  ]------------------------------------------
#
// Obtain relevant data
if ($topic_id)
{
	$sql = "
		SELECT
			f.forum_id, f.forum_name, f.forum_topics

#
#-----[   ]------------------------------------------
#

, f.points_disabled

#
#-----[  ]------------------------------------------
#
	$sql = "SELECT forum_name, forum_topics

#
#-----[   ]------------------------------------------
#

, points_disabled

#
#-----[  ]------------------------------------------
#

	$forum_name = $topic_row['forum_name'];

#
#-----[   ]------------------------------------------
#

	$points_disabled = $topic_row['points_disabled'];

#
#-----[  ]------------------------------------------
#

	$forum_name = $topic_row['forum_name'];

#
#-----[   ]------------------------------------------
#

	$points_disabled = $topic_row['points_disabled'];	
	
#
#-----[  ]------------------------------------------
#
posting.php

#
#-----[  ]------------------------------------------
#

		$select_sql .= (!$submit) ? ', pt.*, u.username, u.user_id
#
#-----[   ]------------------------------------------
#

, u.admin_allow_points

#
#-----[  ]------------------------------------------
#
				if ( !DB()->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Could not insert user_id for poll", "", __LINE__, __FILE__, $sql);
				}

				$message = $lang['VOTE_CAST'];


#
#-----[   ]------------------------------------------
#

				if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['points_poll'] && !$post_info['points_disabled'] )
				{
					if (($userdata['user_id'] !=ANONYMOUS) && ($userdata['admin_allow_points']))
					{
						add_points($userdata['user_id'], $bb_cfg['points_vote']);
					}
				}

#
#-----[  ]------------------------------------------
#
	if (!$error_msg)
	{
		if (!in_array($mode, array('editpost', 'delete', 'poll_delete')))
		{
			$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];

#
#-----[   ]------------------------------------------
#

			$post_data['points_disabled'] = $post_info['points_disabled'];
			$post_data['admin_allow_points'] = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['admin_allow_points'] : $post_info['admin_allow_points'];		

#
#-----[  ]------------------------------------------
#
viewtopic.php
#
#-----[  ]------------------------------------------
#

	$first_post = DB()->fetch_rowset("
		SELECT
		  u.username, u.user_id, u.user_rank, u.user_posts

#
#-----[   ]------------------------------------------
#

, u.admin_allow_points, u.user_points

#
#-----[  ]------------------------------------------
#

$sql = "
	SELECT
	  u.username, u.user_id, u.user_rank, u.user_posts

#
#-----[   ]------------------------------------------
#

, u.admin_allow_points, u.user_points

#
#-----[  ]------------------------------------------
#

		'IP'                 => $ip_btn,

#
#-----[   ]------------------------------------------
#

		'DONATE_POINTS'      => $postrow[$i]['user_points'],

#
#-----[  ]------------------------------------------
#
templates/default/viewtopic.tpl

#
#-----[  ]------------------------------------------
#

		<!-- IF postrow.POSTER_FROM --><p class="from"><em>{L_LOCATION}:</em> {postrow.POSTER_FROM}</p><!-- ENDIF -->

#
#-----[   ]------------------------------------------
#

		<!-- IF postrow.DONATE_POINTS -->{L_SEED_BONUS}&nbsp;{postrow.DONATE_POINTS}<!-- ENDIF -->

#
#-----[  ]------------------------------------------
#
includes/functions_post.php

#
#-----[  ]------------------------------------------
#

	if ($mode != 'poll_delete')

#
#-----[   ]------------------------------------------
#

	global $bb_cfg;

#
#-----[  ]------------------------------------------
#
	if ($mode != 'poll_delete')
	{

#
#-----[   ]------------------------------------------
#

		if ( $bb_cfg['seed_bonus_enabled'] && $bb_cfg['points_post'] && !$post_data['points_disabled'] )
		{
			if ( $mode == 'delete' )
			{
				$points = ( $post_data['first_post'] ) ? $bb_cfg['points_topic'] : $bb_cfg['points_reply'];
				subtract_points($user_id, $points);
			}
			else
			{
				$points = ( $mode == 'newtopic' ) ? $bb_cfg['points_topic'] : $bb_cfg['points_reply'];
				add_points($user_id, $points);
			}
		}

#
#-----[  ]------------------------------------------
#
includes/init_bb.php

#
#-----[  ]------------------------------------------
#

require(INC_DIR .'db/mysql.php');

#
#-----[   ]------------------------------------------
#
require(INC_DIR .'functions_points.php');

#
#-----[  ]------------------------------------------
#
language/lang_russian/lang_admin.php

#
#-----[  ]------------------------------------------
#
// Points System
$lang['POINTS_UPDATED'] = '    ';
$lang['CLICK_RETURN_POINTS'] = ' %s%s,      ';
$lang['POINTS_CONFIG_EXPLIAN'] = '          .';
$lang['POINTS_SYS_SETTINGS'] = '  ';
$lang['POINTS_NAME'] = ' ';
$lang['POINTS_NAME_EXPLAIN'] = '        (, ...)';
$lang['POINTS_DISABLED'] = '  ';

$lang['POINTS_ENABLE_POST'] = '  ';
$lang['POINTS_ENABLE_DONATION'] = '  ';
$lang['POINTS_ENABLE_BROWSE'] = ' %s  ';
$lang['POINTS_ENABLE_POLL'] = '  ';

$lang['POINTS_PER_REPLY'] = '   </br> <h6> ,  </h6>';
$lang['POINTS_PER_TOPIC'] = '    </br> <h6> ,    .</h6>';
$lang['POINTS_PER_VOTE'] = '   </br> <h6> ,  .</h6>';

$lang['POINTS_USER_GROUP_AUTH'] = '  </br> <h6> id ,        ,   id  .</h6>';

$lang['ALLOW_POINTS'] = '  ?';
$lang['POINTS_RESET'] = '  %s';
$lang['POINTS_RESET_EXPLAIN'] = '%s     ,   .';

$lang['POINTS_UPDATE_USER'] = ' %s ';
$lang['CONFIRM_POINTS_UPDATE'] = ' ,   / %s ?';

$lang['POINTS_FORUMS'] = '  ';
$lang['POINTS_FORUMS_EXPLAIN'] = '     / %s   ';

#
#-----[  ]------------------------------------------
#
language/lang_russian/lang_main.php

#
#-----[  ]------------------------------------------
#
// Points System
$lang['POINTS_LINK_TITLE'] = ' <b>%s</b>';
$lang['POINTS_CP'] = ' ';
$lang['POINTS_SYS'] = '  ';
$lang['POINTS_DONATION'] = ' ';
$lang['POINTS_METHOD'] = '';
$lang['POINTS_DONATE'] = '%s%s';
$lang['POINTS_ADD_SUBTRACT'] = '   ';
$lang['POINTS_AMOUNT'] = '';
$lang['POINTS_GIVE_TAKE'] = '    ';
$lang['POINTS_GIVE'] = ' ';
$lang['ADD'] = '';
$lang['SUBTRACT'] = '';
$lang['POINTS_DONATE_TO'] = ',    ';
$lang['POINTS_NO_USERNAME'] = '   .';
$lang['POINTS_NOT_ADMIN'] = '     .';
$lang['POINTS_CANT_TAKE'] = '    %s   .';
$lang['POINTS_THANKS_DONATION'] = '   .';
$lang['CLICK_RETURN_POINTS_DONATE'] = ' %s%s,     ';
$lang['POINTS_CANT_DONATE'] = '      %s  .';
$lang['POINTS_CANT_DONATE_SELF'] = '    %s  .';
$lang['POINTS_USER_DONATION_OFF'] = '    .';
$lang['CLICK_RETURN_POINTSCP'] = ' %s%s,      ';
$lang['POINTS_USER_UPDATED'] = '%s ()  .';
$lang['POINTS_MASS_EDIT'] = '  ';
$lang['POINTS_MASS_EDIT_EXPLAIN'] = '     . </br>         .';
$lang['POINTS_ENTER_SOME_DONATE'] = '    ';
$lang['ALLOW_POINTS'] = '<span class="tor-closed-cp" title="  "></span>';
$lang['ALLOW_POINTS2'] = '<span class="tor-closed-cp" title="  "></span>';
$lang['GUESTS_CANT_POINTS'] = '   %s!';
$lang['DONOR_ENTER_SOME_DONATE'] = '    ';

$lang['NO_SUCH_USER_BOT_P'] = ',   %s   xD';
$lang['NO_SUCH_USER_GUEST_P'] = ',   %s   o_O';

$lang['POINTS_SUBJECT'] = '   ';
$lang['TOTAL_POINTS'] = '   %s';
$lang['AMOUNT_DONATE'] = '%s   %s';
#
#-----[  ]------------------------------------------
#
includes/sessios.php

#
#-----[  ]------------------------------------------
#

		// Update last visit for logged in users
        if ($login)
        {

#
#-----[   ]------------------------------------------
#

			if (!get_bt_userdata($this->data['user_id']))
            {
                require(INC_DIR .'functions_torrent.php');
                generate_passkey($this->data['user_id'], true);
            }

#
#-----[  ]------------------------------------------
#
includes/page_header.php

#
#-----[  ]------------------------------------------
#

	'U_GROUP_CP'         		=> "groupcp.php",

#
#-----[   ]------------------------------------------
#

	'U_SEED_BONUS'         		=> "points.php",

	
#
#-----[  ]------------------------------------------
#

includes/page_header.php

#
#-----[  ]------------------------------------------
#

			<!-- IF SEO_LINK_MEMEBERLIST_PAGE --><a href="{U_MEMBERLIST}"><!-- ENDIF --><b>{L_MEMBERLIST}</b><!-- IF SEO_LINK_MEMEBERLIST_PAGE --></a><!-- ENDIF --><span style="color:#CDCDCD;">|</span>

#
#-----[  ]------------------------------------------
#

			<!-- IF LOGGED_IN && $bb_cfg['seed_bonus_enabled'] && $bb_cfg['points_donate'] --><a href="{U_SEED_BONUS}"><b>{L_SEED_BONUS}</b></a><span style="color:#CDCDCD;">|</span><!-- ENDIF -->
			
#
#-----[  ]------------------------------------------
#
